Skip to content

planner: fix stack overflow caused by folding constant#10174

Merged
qw4990 merged 6 commits intopingcap:masterfrom
qw4990:fix_10156
Apr 18, 2019
Merged

planner: fix stack overflow caused by folding constant#10174
qw4990 merged 6 commits intopingcap:masterfrom
qw4990:fix_10156

Conversation

@qw4990
Copy link
Copy Markdown
Contributor

@qw4990 qw4990 commented Apr 16, 2019

What problem does this PR solve?

Fix #10156.

What is changed and how it works?

When creating dummy function in foldConstant, use NewFunctionBase to avoid it fold it again.

Check List

Tests

  • Unit test

@qw4990 qw4990 added type/bugfix This PR fixes a bug. sig/planner SIG: Planner labels Apr 16, 2019
@qw4990 qw4990 requested review from alivxxx, eurekaka and winoros April 16, 2019 13:13
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 16, 2019

Codecov Report

Merging #10174 into master will decrease coverage by 0.061%.
The diff coverage is 8%.

@@               Coverage Diff                @@
##             master     #10174        +/-   ##
================================================
- Coverage   77.9754%   77.9143%   -0.0611%     
================================================
  Files           407        405         -2     
  Lines         82635      82343       -292     
================================================
- Hits          64435      64157       -278     
- Misses        13424      13441        +17     
+ Partials       4776       4745        -31

Copy link
Copy Markdown
Member

@shenli shenli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to cherry-pick this to the release-2.1 branch?

Comment thread sessionctx/stmtctx/stmtctx.go
Copy link
Copy Markdown
Contributor

@alivxxx alivxxx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@alivxxx alivxxx added the status/LGT1 Indicates that a PR has LGTM 1. label Apr 17, 2019
Copy link
Copy Markdown
Member

@winoros winoros left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why in #10156 , you said we can use ConstItem to fix it, but here just replace NewFunctionInternal by NewFunctionBase?

@qw4990
Copy link
Copy Markdown
Contributor Author

qw4990 commented Apr 17, 2019

Why in #10156 , you said we can use ConstItem to fix it, but here just replace NewFunctionInternal by NewFunctionBase?

Because CorrelatedColumn.ConstItem() always returns true now, it's not correct.
In fact, we have to differentiate between planner-stage and execution-stage for it.

In planner-stage, for example when building scalar function, it should return false because its result depend on column data.
In execution-stage, for example when building range in some operators, since the outer row has been chosen, we can regard it as a const.

I will fix this problem in another PR.
So for this problem, I fix it by the way for simplicity.

@qw4990 qw4990 requested a review from zz-jason April 18, 2019 05:41
@qw4990
Copy link
Copy Markdown
Contributor Author

qw4990 commented Apr 18, 2019

PTAL~

Copy link
Copy Markdown
Member

@zz-jason zz-jason left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zz-jason
Copy link
Copy Markdown
Member

This bug is introduced in #7696
@qw4990 Please cherry pick this fix to the release 2.1 branch

@zz-jason
Copy link
Copy Markdown
Member

/run-all-tests

@qw4990
Copy link
Copy Markdown
Contributor Author

qw4990 commented Apr 18, 2019

/run-unit-test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sig/planner SIG: Planner status/LGT1 Indicates that a PR has LGTM 1. type/bugfix This PR fixes a bug.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stack overflow caused by checking constant wrongly

5 participants